<script type="text/javascript">

$(function(){
	$("input[name='PaperNo']",navTab.getCurrentPanel()).val("111111111111111");
	$.get("applicationSingle/getCardInfo",function(data){
		var contenta="";
		var contentb="<option value=''>请选择</option>";
		var contentc="<option value=''>请选择</option>";
		var i;
		$(data).each(function(n,item){
			var paperType = item.paperType;
			var cardTypeCode = item.cardTypeCode;
			var cardCode = item.cardCode;
			var paperNo = item.paperNo;
			if(paperType==null || paperType==""){
				paperType = "00";
			}
			console.log("paperType===>"+paperType);
			if(cardTypeCode==null || cardTypeCode==""){
				cardTypeCode = "0";
			}
			console.log("cardTypeCode===>"+cardTypeCode);
			if(cardCode==null || cardCode==""){
				cardCode = "80"
			}
			console.log("cardCode===>"+cardCode);
			
			for(i=0;i<item.cdPhysicsTypes.length;i++){
				if(item.cdPhysicsTypes[i].cardTypeCode==cardTypeCode){
					contenta+="<option value="+item.cdPhysicsTypes[i].cardTypeCode+" selected>"
					+item.cdPhysicsTypes[i].cardTypeName+"</option>"
				}else{
					contenta+="<option value="+item.cdPhysicsTypes[i].cardTypeCode+">"
					+item.cdPhysicsTypes[i].cardTypeName+"</option>"
				}
				
			};
			for(i=0;i<item.cdProDefinitions.length;i++){
				//20190225 hgl 修改以下9行
				if(item.cdProDefinitions[i].cardTypeCode=="2"){
					if(item.cdProDefinitions[i].cardpCode==cardCode){
						contentb+="<option value="+item.cdProDefinitions[i].cardpCode+" selected>"
						+item.cdProDefinitions[i].cardpName+"</option>"
					}else{
						contentb+="<option value="+item.cdProDefinitions[i].cardpCode+">"
						+item.cdProDefinitions[i].cardpName+"</option>"
					}
				}				
			}
			for(i=0;i<item.certificates.length;i++){
				if(item.certificates[i].certificateType==paperType){
					contentc+="<option value="+item.certificates[i].certificateType+">"
					+item.certificates[i].certificatesName+"</option>"
				}else{
					contentc+="<option value="+item.certificates[i].certificateType+">"
					+item.certificates[i].certificatesName+"</option>"
				}
			}
			$("#PaperType").html(contentc);
			$("#CardType").html(contenta);
			$("#CardCode").html(contentb);
			$("#PaperNo").val(paperNo);		
		});
	},"json");
	
	$("#CardCode").change(function(){
		var value=$("#CardCode").val();
		if(value=="15" || value=="16"){
			$("#CardType").attr("disabled","disabled");
			$("#CardType").val("0");
		}else{
			$("#CardType").val("");
			$("#CardType").removeAttr("disabled");
		}
	}); 
	$("#submit").click(function(){
		$("#CardType").removeAttr("disabled");
	});
	
})
function checkPaper(){
		var paperCode = $("#PaperType").val();
		var card = $("#PaperNo").val();
		return checkCard(card,paperCode);	
}

function readIPCard(sel){
	$("input[name='PaperNo']",navTab.getCurrentPanel()).val("");
	var paperType=$(sel).val();
	if(paperType=="00"){
		var result=ReadIdentityCard();
		if(result!=""){
			$("input[name='PaperNo']",navTab.getCurrentPanel()).val(result)
		}
	}
}

</script>
<div class="pageHeader">
<object id="GPRActiveX" height="0" classid="clsid:81AD3409-2634-4394-8F0C-99CD5B0A6D75"></object>
	<form method="post" action="applicationSingle/validate"
		class="pageForm required-validate"
		onsubmit="return validateCallback(this,navTabAjaxDone);">
		<div class="searchBar">
			<div class="row" style="padding: 0 10px;">
				<div class="col-md-6 col-sm-12">
					<p>
						<label>证件类型：</label><select id="PaperType" name="PaperType"
							class="validRequired " onchange="readIPCard(this)"></select>
					</p>
				</div>
				<div class="col-md-6 col-sm-12">
					<p>
						<label>证件号码：</label><input id="PaperNo" name="PaperNo" type="text"
							size="21" class="validRequired" />
					</p>
				</div>
			</div>
			<div class="row" style="padding: 0 10px;">
				<div class="col-md-6 col-sm-12">
					<p>
						<label>卡产品：</label><select id="CardCode" name="CardCode"
							class="required"></select>
					</p>
				</div>
				<div class="col-md-6 col-sm-12">
					<p>
						<label>卡类型：</label><select id="CardType" name="CdPhysicsType"
							class="required"></select>
					</p>
				</div>
			</div>
			<div class="subBar">
				<ul>
					<li>
						<div class="buttonActive">
							<div class="buttonContent">
								<button id="submit" type="submit" onclick="return checkPaper()">申请登记</button>
							</div>
						</div>
					</li>
				</ul>
			</div>
		</div>
	</form>
</div>